Model
Now that the dataset is fully preprocessed and has the right features, the Ridge estimator is fitted and feature importance is computed.
regressor = Ridge(random_state=42)
regressor.fit(x_new, y)
weights = regressor.coef_
feature_importances = np.abs(weights)
feature_importances = feature_importances / feature_importances.sum()
importances = sorted([[name, importance] for name, importance in zip(x_new.columns, feature_importances)], key=lambda x: x[1], reverse=True)
for i in range(len(importances)):
if weights[i] < 0:
importances[i][1] *= -1
print(importances[i][0] + ": " + str(importances[i][1]))
# MACD Signal: -0.24596071114821536
# DMA 200: -0.20453670942424465
# DMA 200 previous day: 0.19676823240750368
# MACD Signal Previous Day: -0.1687308183726426
# MACD: 0.06514313818068215
# DMA 50: 0.0547749071267598
# DMA 50 previous day: -0.048447982280562914
# Current Price: -0.011503284442439858
# Low price: 0.002074806587562356
# High price: -0.001976060945534257
# High price all time: 8.334908385237595e-05